import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const cutterUrl = CommonConfig.cutterUrl + '/v1'

/**
 * 列举仓库
 * @returns {Promise<unknown>}
 */
export function getWarehousesList (params) {
  const url = cutterUrl + '/warehouses:page'

  return axiosInstance.get(url, { params }).then(resp => {
    return Promise.resolve(resp.data)
  })
}

/**
 * 添加仓库
 * @returns {Promise<unknown>}
 */
export function addWarehouses (params) {
  const url = cutterUrl + '/warehouses'

  return axiosInstance.post(url, params).then(resp => {
    return Promise.resolve(resp)
  })
}

/**
 * 编辑仓库
 * @returns {Promise<unknown>}
 */
export function editWarehouses (params, id) {
  const url = cutterUrl + '/warehouses/' + id

  return axiosInstance.patch(url, params).then(resp => {
    return Promise.resolve(resp)
  })
}

/**
 * 删除仓库
 * @returns {Promise<unknown>}
 */
export function delWarehouses (id) {
  const url = cutterUrl + '/warehouses/' + id

  return axiosInstance.delete(url).then(resp => {
    return Promise.resolve(resp)
  })
}
